<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript">
        //工厂方法学习
        function Person(name,age,gender){
            console.log("Person");
            this.name = name;
            this.age = age;
            this.gender = gender;
            this.sayName = function(){
                console.log(this.name);
            }
        }
        function createPerson(name,age,gender){
            var obj = new Person();
            obj.name = name;
            obj.age = age;
            obj.gender = gender;
            return obj;
        }
        var peter =  createPerson("Peter",18,"male")
        var josh =  createPerson("Josh",29,"male")
        var joe =  createPerson("Joe",18,"female")
        peter.sayName();
        josh.sayName();
        joe.sayName();

        function Dog(name,age,gender){
            this.name = name;
            this.age = age;
            this.gender = gender;
        }
        console.log(peter instanceof Person);
        console.log(peter instanceof Dog);

        //constructor method     
        

    </script>
</head>
<body>
    
</body>
</html>